<div class="col-md-3">

  <script>
    $D = {
      uid: <%= current_user.uid %>,
      type: 'note',
      warn_image: <%= params[:template] == "question" %>
    }
  </script>

  <%= javascript_include_tag "post" %>
  <%= javascript_include_tag "editorToolbar" %>

  <% if params[:template] == "question" %>
    <h4 class="d-lg-none"><%=translation('dashboard._header.dropdown.ask_question')%></h4>
    <div id="research-note-detail" class="d-none d-lg-inline">
      <h4><i class="fa fa-question-circle"></i> Use this form to ask Question about <b><%= @node.power_tag('question') if @node %></b></h4>
      <% if @node && Tag.follower_count(@node.power_tag('question')) > 0 %>
        <div class="alert alert-success" role="alert"><%= Tag.follower_count(@node.power_tag('question')) %> people have signed up to answer questions on this topic.</div>
      <% end %>
      <p>Here you can ask a question to the Public Lab community to help you in your environmental exploration. This is a great space to ask whether a method exists for identifying a possible pollutant, or ask about details of a specific technique for identifying a pollutant.</p>
      <p>You can add more tags in the tags section below to further relate your question. You can also change the main tag of the question by renaming the part after <b><i>question:</i></b> tag</p>
      <p>New to Public Lab? Take a minute to read the Q &amp; A wiki before posting your question</p>
      <h4><a href="//<%= request.host %>/wiki/public-lab-q-and-a">Learn more &raquo;</a></h4>
    </div>

  <% else %>
    <h3 class="d-none d-lg-block d-xl-none"><i class="fa fa-file"></i> What's a <br />research note?</h3>
    <h4 class="d-lg-none d-xl-block"><i class="fa fa-file"></i> What's a research note? <a onClick="$('#research-note-detail').toggleClass('d-block')">Learn more &raquo;</a><br /></h4>

    <div id="research-note-detail" class="d-none d-lg-block">
      <p><%= raw translation('editor.post.research_note') %></p>
      <p><b>Research notes can include:</b></p>
      <ul>
        <li>photos of what you've made</li>
        <li>requests for troubleshooting</li>
        <li>proposals for new projects</li>
        <li>announcements of events</li>
        <li>reports from a field test or meetup</li>
        <li>etc!</li>
      </ul>
      <hr />
      <p><b><a href="//www.youtube.com/watch?v=rsy__zTTh8c" target="_blank"><i class="fa fa-film"></i> Watch a 30 second video on posting research notes &raquo;</a></b></p>
      <hr />
      <div class="navbar">
        <ul class="navbar-nav">
          <li class="nav-item navbar-brand">More</li>
          <li class="nav-item"><a class="nav-link" href="/getting-started">Getting started with Public Lab</a></li>
          <li class="nav-item"><a class="nav-link" href="/wiki/posting-research">About posting research</a></li>
          <li class="nav-item"><a class="nav-link" href="/wiki/authoring-help#Advanced+formatting">Advanced formatting</a></li>
        </ul>
      </div>
    </div>
  <% end %>
</div>

<div class="col-md-9">
  <%
  if @node && params[:action] != "create"
    url = { :controller => "notes", :action => "update", :id => params[:id] }
  else
    url = { :controller => "notes", :action => "create", :id => params[:id] }
  end
  %>
  <div class="card bg-light">
    <div class="card-body">
      <%= form_for :node, :as => :drupal_node, :url => url do |f| %>
        <%= render partial: 'layouts/errorMessages', locals: { model: @node } if @node.present? %>
      <% end %>

    <div id="legacy-editor-container" class="card-body">
      <%= form_for :revision, :as => :revision, :url => url, :html => {:class => "form well legacy-form row"} do |f| %>

        <%= render partial: 'layouts/errorMessages', locals: { model: @revision } if @revision.present? %>
        <%= render :partial => "editor/main_image" %>

        <div class="col-lg-9 order-lg-1">

          <% if params[:template] == "question" %>
            <h3>Ask a question of the community</h3>
          <% else %>
            <h3>Share your work</h3>
          <% end %>

          <div class="form-group">
            <input id="title" tabindex="1" name="title" class="form-control" placeholder="<% if params[:template] == "question" %>Ask a question as specifically as possible<% else %>Title your post descriptively<% end %>" value="<%= if @node then @node.title else params[:title] end %>"/>
          </div>

          <input class="form-control" id="main_image" type="hidden" name="main_image" value="<% if @node && @node.main_image(:rails) %><%= @node.main_image(:rails).id %><% else %><%= params[:main_image] %><% end %>" />
          <input class="form-control" id="node_images" type="hidden" name="node_images" value="" />

          <%= render :partial => 'editor/editor' %>

          <div class="input-group tags-input">
            <div class="input-group-prepend">
                <span class="input-group-text"><i class="fa fa-tags"></i></span>
            </div>
            <input autocomplete="off" class="form-control" id="taginput" tabindex="3" name="tags" type="text" <% if params[:tags] || (@node && @node.power_tag('question')) || (@node && @node.tagnames) %>value="<%= params[:tags] || @node.tagnames.join(',') %><%= ','+@node.power_tag('question') if @node && @node.power_tag('question') != '' %>"<% else %>placeholder="balloon-mapping,gulf-coast"<% end %> data-provide="typeahead" />
          </div>

          <input name="remote" type="hidden" value="true"/>

          <p class="d-none alert alert-warning">Consider adding a lead image to illustrate your post! (see above right)</p>
          <br />

          <% if current_user.first_time_poster %>
            <p class="moderation-notice">Hi! Just letting you know ahead of time that everyone's first posts to this website are <a href='/wiki/moderation'>moderated</a> due to issues we've had with spam. Thanks for your patience!</p>
          <% end %>

          <a id="publish" tabindex="5" class="publish btn btn-primary btn-lg">Publish</a>
          <a tabindex="6" id="toggle-preview-button-main" data-previewing-text="<%= t('wiki.edit.previewing_text') %>" class="btn btn-outline-secondary btn-lg preview-btn" onClick="$E.toggle_preview()"><%= t('wiki.edit.preview') %></a>

          <%= render partial: 'editor/event' %>

        </div>

        <div class="order-lg-3">
          <br />
          <p class="col-lg-12">By publishing, you agree to <a target="_blank" href="/licenses">open source your work</a> so that others may use it.</p>
          <br />
        </div>
        <% end %>

    </div>
  </div>
</div>
